home *** CD-ROM | disk | FTP | other *** search
Java Source | 1998-06-30 | 3.2 KB | 122 lines |
- /*
- * @(#)MockAttributeSet.java 1.2 97/12/16
- *
- * Copyright (c) 1997 Sun Microsystems, Inc. All Rights Reserved.
- *
- * This software is the confidential and proprietary information of Sun
- * Microsystems, Inc. ("Confidential Information"). You shall not
- * disclose such Confidential Information and shall use it only in
- * accordance with the terms of the license agreement you entered into
- * with Sun.
- *
- * SUN MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT THE SUITABILITY OF THE
- * SOFTWARE, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
- * PURPOSE, OR NON-INFRINGEMENT. SUN SHALL NOT BE LIABLE FOR ANY DAMAGES
- * SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR DISTRIBUTING
- * THIS SOFTWARE OR ITS DERIVATIVES.
- *
- */
- package com.sun.java.swing.text.rtf;
-
- import java.util.Dictionary;
- import java.util.Enumeration;
- import com.sun.java.swing.text.AttributeSet;
- import com.sun.java.swing.text.MutableAttributeSet;
-
-
- /* This AttributeSet is made entirely out of tofu and Ritz Crackers
- and yet has a remarkably attribute-set-like interface! */
- class MockAttributeSet
- implements AttributeSet, MutableAttributeSet
- {
- public Dictionary backing;
-
- public boolean isEmpty()
- {
- return backing.isEmpty();
- }
-
- public int getAttributeCount()
- {
- return backing.size();
- }
-
- public boolean isDefined(Object name)
- {
- return ( backing.get(name) ) != null;
- }
-
- public boolean isEqual(AttributeSet attr)
- {
- throw new InternalError("MockAttributeSet: charade revealed!");
- }
-
- public AttributeSet copyAttributes()
- {
- throw new InternalError("MockAttributeSet: charade revealed!");
- }
-
- public Object getAttribute(Object name)
- {
- return backing.get(name);
- }
-
- public void addAttribute(Object name, Object value)
- {
- backing.put(name, value);
- }
-
- public void addAttributes(AttributeSet attr)
- {
- Enumeration as = attr.getAttributeNames();
- while(as.hasMoreElements()) {
- Object el = as.nextElement();
- backing.put(el, attr.getAttribute(el));
- }
- }
-
- public void removeAttribute(Object name)
- {
- backing.remove(name);
- }
-
- public void removeAttributes(AttributeSet attr)
- {
- throw new InternalError("MockAttributeSet: charade revealed!");
- }
-
- public void removeAttributes(Enumeration en)
- {
- throw new InternalError("MockAttributeSet: charade revealed!");
- }
-
- public void setResolveParent(AttributeSet pp)
- {
- throw new InternalError("MockAttributeSet: charade revealed!");
- }
-
-
- public Enumeration getAttributeNames()
- {
- return backing.keys();
- }
-
- public boolean containsAttribute(Object name, Object value)
- {
- throw new InternalError("MockAttributeSet: charade revealed!");
- }
-
- public boolean containsAttributes(AttributeSet attr)
- {
- throw new InternalError("MockAttributeSet: charade revealed!");
- }
-
- public AttributeSet getResolveParent()
- {
- throw new InternalError("MockAttributeSet: charade revealed!");
- }
- }
-
-
-